<template>
  <view class="tab-bar">
    <view 
      v-for="(tab, index) in tabs" 
      :key="index"
      class="tab-item"
      :class="{ active: currentTab === index }"
      @tap="$emit('change', index)"
    >
      <text class="tab-text">{{ tab }}</text>
      <view v-if="currentTab === index" class="tab-indicator"></view>
    </view>
  </view>
</template>

<script setup lang="ts">
interface Props {
  tabs: string[];
  currentTab: number;
}

defineProps<Props>();
defineEmits(['change']);
</script>

<style scoped>
.tab-bar {
  display: flex;
  background-color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1rpx solid #f0f0f0;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 30rpx 0;
  position: relative;
}

.tab-text {
  font-size: 28rpx;
  color: #666;
}

.tab-item.active .tab-text {
  color: #00C853;
  font-weight: bold;
}

.tab-indicator {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60rpx;
  height: 4rpx;
  background-color: #00C853;
  border-radius: 2rpx;
}
</style>